package 面试;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class 十进制转二进制 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入十进制数字：");
        int num = scanner.nextInt();
        System.out.println(toBinary(num));
    }
    public static Integer toBinary(int number){

        int binaryInt = 0;
        int count = 0;
        while(number > 0){
            int  i = number % 2;
            number = number / 2;
            binaryInt = (int) (binaryInt + (i * Math.pow(10, count)));
            count++;
        }
        return binaryInt;
    }
}
